package handlers;


import java.io.IOException;
import java.net.Socket;

import common.classes.HeaderWorker;


public class Handler {
	Handler next;
	
	public Handler() {
		this.next = null;
	}
	
	public Handler(Handler next) {
		this.next = next;
	}
	
	protected void closeSocket(Socket socket) {
		try {
			socket.close();
		} catch (IOException e) {
			System.err.println(e);
		}
	}
	
	public void parseRequest(Socket socket, HeaderWorker header, String error) {
		if (next != null) next.parseRequest(socket, header, error);
		else  try{
			socket.close();
		} catch (IOException e) {
			System.err.println(e);
		}
	}

	public Handler getNext() {
		return next;
	}

	public void setNext(Handler next) {
		this.next = next;
	}
}
